//
//  OrderCollectionViewCell.m
//  UniversalApp
//
//  Created by 志刚杨 on 2018/2/3.
//  Copyright © 2018年 voidcat. All rights reserved.
//

#import "OrderCollectionViewCell.h"
#import <SDWebImage/UIImageView+WebCache.h>
@implementation OrderCollectionViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    [self setUI];
}

-(void)setUI
{
    self.lableId.textColor = MainColor;
    self.headerImage.layer.cornerRadius = 25;
    self.headerImage.layer.masksToBounds = YES;
    self.headerImage.contentMode = UIViewContentModeScaleAspectFill;
    self.labCoin.font = DEFAULT_FONT(11);
    self.labCoin.textColor = MainColor;
}

-(void)setModel:(OrderModel *)model
{
    _model = model;
    self.lableId.text = model.sum;
    
    if(KIOSBASE)
    {
        self.headerImage.image = [[CYCommon sharedCYCommon] getKatongImageWidthID:model.id];
    }
    else{
        
        [self.headerImage sd_setImageWithURL:[[CYURLUtils sharedCYURLUtils] safeUrl:model.avatar] placeholderImage:[[CYCommon sharedCYCommon] getEpmayImage]];
    }
    
    self.usernickname.text = model.user_nickname;
    self.labCoin.text = model.zsum;
    self.local.text = model.address;
    [self.level getViewType:model.sex AndLevel:model.level];

    

    if([self.model.is_online isEqualToString:@"1"]){
        UIImage *radImage = [[UIImage imageWithColor:MainColor size:CGSizeMake(3, 3)] imageByRoundCornerRadius:1.5];
        self.imgDot.image = radImage;
    }
    else
    {
        UIImage *radImage = [[UIImage imageWithColor:CLightGray size:CGSizeMake(3, 3)] imageByRoundCornerRadius:1.5];
        self.imgDot.image = radImage;
    }
    
//    NSLog(@"%d")
    if([model.sum intValue] > 3)
    {
        self.ImagEcrown.hidden = YES;
        [_lableId mas_updateConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self);
            make.left.equalTo(self).offset(10);
        }];
    }
    else
    {
        [_lableId mas_updateConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self).offset(5);
            make.left.equalTo(self).offset(10);
        }];
        
        [_ImagEcrown mas_updateConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(_lableId.mas_top).offset(-1.5);
            make.centerX.equalTo(_lableId);
        }];
        
    }
    
    if([self.type isEqualToString:@"2"])
    {
        [self.level setTintColor:kGoldenColor];
        self.level.ghostColor = kGoldenColor;
        self.labCoin.textColor = kGoldenColor;
        self.imgEarncoin.image = IMAGE_NAMED(@"rank_paycoin");
        
        self.ImagEcrown.image = IMAGE_NAMED(@"rank_wealth_total");
        self.lableId.textColor = kGoldenColor;
    }
    
    
//    if(mode)
}

@end
